package org.ptkparty.client.mapper;

import org.ptkparty.client.ClientFactory;
import org.ptkparty.client.activity.AddGameActivity;
import org.ptkparty.client.activity.ChampionshipsActivity;
import org.ptkparty.client.activity.PlacesActivity;
import org.ptkparty.client.activity.PlayersActivity;
import org.ptkparty.client.activity.PrepareGamesActivity;
import org.ptkparty.client.activity.ProfilActivity;
import org.ptkparty.client.activity.ResultsActivity;
import org.ptkparty.client.activity.ScalesActivity;
import org.ptkparty.client.activity.ShowGamesActivity;
import org.ptkparty.client.activity.StatsActivity;
import org.ptkparty.client.place.AddGamePlace;
import org.ptkparty.client.place.ChampionshipsPlace;
import org.ptkparty.client.place.PlacesPlace;
import org.ptkparty.client.place.PlayersPlace;
import org.ptkparty.client.place.PrepareGamesPlace;
import org.ptkparty.client.place.ProfilPlace;
import org.ptkparty.client.place.ResultsPlace;
import org.ptkparty.client.place.ScalesPlace;
import org.ptkparty.client.place.ShowGamesPlace;
import org.ptkparty.client.place.StatsPlace;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class PTKPartyActivityMapper implements ActivityMapper {

	private ClientFactory clientFactory = null;

	public PTKPartyActivityMapper(ClientFactory clientFactory) {
		super();
		this.clientFactory = clientFactory;
	}

	@Override
	public Activity getActivity(Place place) {
		Activity activity = null;

		if (place instanceof ProfilPlace) {
			activity = new ProfilActivity(clientFactory, ((ProfilPlace) place).getName(), ((ProfilPlace) place).getPlayer());
		} else if (place instanceof ChampionshipsPlace) {
			activity = new ChampionshipsActivity(clientFactory);
		} else if (place instanceof PlayersPlace) {
			activity = new PlayersActivity(clientFactory);
		} else if (place instanceof ScalesPlace) {
			activity = new ScalesActivity(clientFactory);
		} else if (place instanceof AddGamePlace) {
			activity = new AddGameActivity(clientFactory, ((AddGamePlace) place).getName(), ((AddGamePlace) place).getGame());
		} else if (place instanceof ResultsPlace) {
			activity = new ResultsActivity(clientFactory, ((ResultsPlace) place).getName());
		} else if (place instanceof ShowGamesPlace) {
			activity = new ShowGamesActivity(clientFactory, ((ShowGamesPlace) place).getName());
		} else if (place instanceof PrepareGamesPlace) {
			activity = new PrepareGamesActivity(clientFactory, ((PrepareGamesPlace) place).getName());
		} else if (place instanceof StatsPlace) {
			activity = new StatsActivity(clientFactory, ((StatsPlace) place).getName());
		} else if (place instanceof PlacesPlace) {
			activity = new PlacesActivity(clientFactory);
		}

		return activity;
	}
}
